package com.myproject.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ErrorCode {
    SUCCESS(200, "操作成功"),
    PARAM_ERROR(400, "参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    INTERNAL_ERROR(500, "系统内部错误"),

    // 业务错误码
    USER_EXIST(1001, "用户已存在"),
    USER_NOT_EXIST(1002, "用户不存在"),
    PASSWORD_ERROR(1003, "密码错误"),
    TOKEN_EXPIRED(1004, "令牌已过期"),
    TOKEN_INVALID(1005, "无效令牌"),
    TOKEN_ERROR(1006, "令牌解析错误"),
    PARAM_VALID_ERROR(1007, "参数校验失败"),
    PERMISSION_DENIED(1008, "权限不足"),
    SAVE_FAILED(1009, "保存失败"),
    UPDATE_FAILED(1010, "更新失败"),
    DELETE_FAILED(1011, "删除失败"),
    
    // 系统错误码
    VALIDATION_ERROR(400, "参数验证失败"),
    SYSTEM_ERROR(500, "系统内部错误"),
    
    // 系统级错误 (50xxx)
    DB_CONNECTION_FAILED(50011, "数据库连接失败"),
    NETWORK_TIMEOUT(50021, "网络通信超时"),
    SQL_ERROR(50031, "SQL执行错误，请检查SQL语法或表结构"),
    
    // 业务级错误 (60xxx)
    INVALID_PARAM(60001, "参数校验失败"),
    DATA_NOT_FOUND(60041, "数据不存在");

    private final int code;
    private final String message;
}